package fr.emse.tatiana.importexport;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;

public class ExportCorpusWizard extends Wizard {

	private String folder;
	private String name;
	private List list;
	
	IProject selection;
	ExportCorpusWizardMainPage choosecorpus;
	public void init(IWorkbench workbench, IProject selection) {
		// TODO Auto-generated method stub
		this.selection=selection;
	}

	public void addPages() {
		// TODO Auto-generated method stub
		choosecorpus = new ExportCorpusWizardMainPage(selection);
		addPage(choosecorpus);
	}

	

	public boolean performFinish() {
		return choosecorpus.finish(getDestinationValue());

	}

	public void setPath(String path) {
		this.folder=path;

	}
	public void setFileName(String file) {
		this.name=file;

	}



	public String getDestinationValue() {
		String idealSuffix = ".zip";
		String destinationText = folder+File.separator+name;
		destinationText=destinationText.trim();
		if (destinationText.length() != 0
				&& !destinationText.endsWith(File.separator)) {
			int dotIndex = destinationText.lastIndexOf('.');
			if (dotIndex != -1) {
				int pathSepIndex = destinationText.lastIndexOf(File.separator);
				if (pathSepIndex != -1 && dotIndex < pathSepIndex) {
					destinationText += idealSuffix;
				}
			} else {
				destinationText += idealSuffix;
			}
		}

		return destinationText;
	}

	public void setResource(List list) {
		// TODO Auto-generated method stub
		this.list=list;
	}

}
